using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Comments : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string blogID = Request.Params["blogID"].ToString();
          //  Label1.Text = blogID.ToString();
        }
        catch (Exception ex)
        {
          //  Label1.Text =ex.Message.ToString()+"Sorry you are super smart or super fool";
        
        }


    }
    protected void OnSuccess()
    {
        try
        {

            string CommentDesc = txtComment.Text;
            string CommentBy = txtNickName.Text;
            string email = txtEmail.Text;
            string IPAddress = Request.UserHostAddress;
            string CommentDate = System.DateTime.Now.ToString();
            string IsPublished = "False";
            string BlogID = Request.Params["blogID"].ToString();



            string insertCommand = "INSERT INTO BlogComment" +
                          "(CommentBy, CommentDesc, IPAddress, BlogID, IsPublished, CommentDate, Email)" +
                           "VALUES (@CommentBy,@CommentDesc,@IPAddress,@BlogID,@IsPublished,@CommentDate,@Email)";


            SqlDataSource3.InsertCommand = insertCommand;

            SqlDataSource3.InsertParameters.Add("CommentBy", CommentBy);
            SqlDataSource3.InsertParameters.Add("CommentDesc", CommentDesc);
            SqlDataSource3.InsertParameters.Add("IPAddress", IPAddress);
            SqlDataSource3.InsertParameters.Add("BlogID", BlogID);
            SqlDataSource3.InsertParameters.Add("IsPublished", TypeCode.Boolean,IsPublished);
            SqlDataSource3.InsertParameters.Add("CommentDate", TypeCode.DateTime, CommentDate);
            SqlDataSource3.InsertParameters.Add("Email", email);

            SqlDataSource3.Insert();
            SqlDataSource3.InsertParameters.Clear();




            //  string connectionString = ConfigurationManager.ConnectionStrings["Personal"].ConnectionString.ToString();
            //  SqlDataSource sqlDataSource = new SqlDataSource(connectionString);

            // sqlDataSource.InsertCommand("INSERT INTO BlogComment values (@ "

            Panel1.Visible = false;
            Panel3.Visible = true;
            //Panel1.Dispose();
            // Label1.Text = "ok and fine";
            //Captcha1.Message = "ok and fine";
        }
        catch (Exception ex)
        {
            txtComment.Text = ex.Message.ToString();
        
        }
     }
    protected void OnFailure()
    {
       // Label1.Text = "Problem";
        Captcha1.Message = "The text you entered was not correct. Please try again:";
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {

    }
}
